import React, { useEffect, useState } from 'react'

export default function App() {
  const [Person, setPerson] = useState([
    { id: "001", name: "放开我徒弟" },
    { id: "002", name: "雷公" },
    { id: "003", name: "还有唐老鸭" },
  ])

  const changePerson = () => {
    setPerson([...Person, { id: Date.now(), name: Date.now() }])
  }

  useEffect(() => {
    console.log("Person改变了");
  },[Person])

  return (
    <div>
      <button onClick={changePerson}>添加数据</button>
      <ul>
        {
          Person.map(item => {
            return <li key={item.id}>{item.name}</li>
          })
        }
      </ul>
    </div>
  )
}
